import { EnumUtil, MapUtil } from '/@/lib/enum';

/** APP **/
export const APP_ENUM = EnumUtil.create({
  XSTAGE: ['XSTAGE', '基础配置', '', { tag: 'xstage' }],
  ERP: ['ERP', '精益ERP', '', { tag: 'erp' }],
  MES: ['MES', '制造执行', '', { tag: 'erp' }],
  QMS: ['QMS', '质量管理', '', { tag: 'erp' }],
  WMS: ['WMS', '智能仓储', '', { tag: 'erp' }],
  SCADA: ['SCADA', '数据采集', '', { tag: 'scada' }],
  EAM: ['EAM', '设备资产', '', { tag: 'eam' }],
  DCC: ['DCC', '文件管理', '', { tag: 'dcc' }],
});

/** 语言 **/
export const LANG_ENUM = EnumUtil.create({
  CN: ['zh-CN', '简体中文'],
  TW: ['zh-TW', '繁體中文'],
  EN: ['en', 'English'],
});

/** 颜色 **/
export const COLOR_ENUM = EnumUtil.create({
  BLACK_LV3: ['#3d3b4f', '玄青'],
  BLACK_LV2: ['#50616d', '墨色'],
  BLACK_LV1: ['#758a99', '墨灰'],

  RED_LV3: ['#ff2121', '大红'],
  RED_LV2: ['#ff2d51', '火红'],
  RED_LV1: ['#ef7a82', '嫣红'],

  ORANGE_LV3: ['#ff7500', '橘黄'],
  ORANGE_LV2: ['#ffa400', '橙黄'],
  ORANGE_LV1: ['#ffc773', '姜黄'],

  YELLOW_LV3: ['#e9bb1d', '雄黄'],
  YELLOW_LV2: ['#eacd76', '金色'],
  YELLOW_LV1: ['#eedeb0', '牙色'],

  GREEN_LV3: ['#0aa344', '青葱'],
  GREEN_LV2: ['#2add9c', '碧绿'],
  GREEN_LV1: ['#7fecad', '缥'],

  CYAN_LV3: ['#48c0a3', '青碧'],
  CYAN_LV2: ['#7bcfa6', '石青'],
  CYAN_LV1: ['#c0ebd7', '青白'],

  BLUE_LV3: ['#177cb0', '靛'],
  BLUE_LV2: ['#44cef6', '蓝'],
  BLUE_LV1: ['#70f3ff', '蔚蓝'],

  PURPLE_LV3: ['#56004f', '紫棠'],
  PURPLE_LV2: ['#8d4bbb', '紫色'],
  PURPLE_LV1: ['#cca4e3', '丁香色'],
});

/** websocket **/
export const WEBSOCKET_ENUM = EnumUtil.create({
  ONLINE: ['online', '上线', '', { code: 1, msgType: 'warning' }],
  NOTICE: ['notice', '通知', '', { code: 1, msgType: 'info' }],
  PUSH: ['push', '推送', '', { code: 3, msgType: 'success' }],
  ONLINE_TEST: ['onlineTest', '上线测试', '', { code: 4, msgType: 'warning' }],
  NOT_TYPE: ['fail', '不存在的类型', '', { code: -10, msgType: 'error' }],
  ERROR: ['error', '错误', '', { code: -404, msgType: 'error' }],
  OFFLINE: ['offline', '强制下线', '', { code: -2, msgType: 'warning' }],
});

/** 系统模块 **/
export const SYSTEM_MODULES_MAP = MapUtil.create({
  PC: 'PC',
  PDA: 'PDA',
  PAD: 'PAD',
});

/** 比较符 **/
export const SYMBOL_ENUM = EnumUtil.create({
  EQUAL: [
    'equal',
    '等于',
    '',
    {
      setParams(params, key, value) {
        params[key] = value;
        return params;
      },
    },
  ],
  LIKE: [
    'like',
    '包含',
    '',
    {
      setParams(params, key, value) {
        params[key] = `%${value}%`;
        return params;
      },
    },
  ],
  LIKE_START: [
    'likeStart',
    '开始以',
    '',
    {
      setParams(params, key, value) {
        params[key] = `%${value}`;
        return params;
      },
    },
  ],
  LIKE_END: [
    'likeEnd',
    '结束以',
    '',
    {
      setParams(params, key, value) {
        params[key] = `${value}%`;
        return params;
      },
    },
  ],
});

/** 比较符-占位符 **/
export const SYMBOL_PLACEHOLDER_ENUM = EnumUtil.create({
  USER: ['$$USER', '当前用户'],
  CUSTOMER: ['$$CUSTOMER', '当前用户关联的客户'],
});

/** 系统参数 **/
export const SYSTEM_PARAMETER_MAP = MapUtil.create({
  RECONCILIATION_CONFIRMATION_DATE: 'ReconciliationConfirmationDate',
  PASS_THROUGH: 'PassThrough',
  MATERIAL_RECEIVE_TOLERANCE: 'MaterialReceiveTolerance',
});

/**
 * 系统固定角色：编码、名称不允许修改
 *    超级管理员：SUPER_ADMIN
 *    管理员：ADMIN
 *    销售员：SALESMAN
 *    采购员：BUYER
 *    收货员：RECEIVING_CLERK
 *    操作员：SUPPORT_PERSONNEL
 *    仓库负责人：WAREHOUSE_MANAGER
 */
export const SYSTEM_ROLES_MAP = MapUtil.create({
  SUPER_ADMIN: 'SUPER_ADMIN',
  ADMIN: 'ADMIN',
  SALESMAN: 'SALESMAN',
  BUYER: 'BUYER',
  RECEIVING_CLERK: 'RECEIVING_CLERK',
  SUPPORT_PERSONNEL: 'SUPPORT_PERSONNEL',
  WAREHOUSE_MANAGER: 'WAREHOUSE_MANAGER',
});

/**
 * 系统固定用户：编码、名称不允许修改
 *    管理员：ADMIN
 */
export const SYSTEM_USERS_MAP = MapUtil.create({
  ADMIN: 'ADMIN',
});

/** 系统固定编码规则 **/
export const SYSTEM_CODING_RULE = MapUtil.create({
  MATERIAL_CODE: 'materialCode',
  PRODUCT_CODE: 'productCode',
  SEMI_MANUFACTURED_CODE: 'semiManufacturedCode',
  SUPPLIERCODERULE: 'supplierCodeRule',
});

export const PLC_ROLE = MapUtil.create({
  MATERIAL_CODE: 'materialCode',
  PRODUCT_CODE: 'productCode',
  SEMI_MANUFACTURED_CODE: 'semiManufacturedCode',
  SUPPLIERCODERULE: 'supplierCodeRule',
});

// 文件类型
export const FILE_TYPES =
  '.png, .jpg, .jpeg, .bmp, .gif, .pdf, .doc, .docx, .ppt, .pptx, .rar, .zip, .7z, .mp4, .m2v, .mkv, .rmvb, .wmv, .avi, .flv, .mov, .m4v, .mp3, .wav, .txt, .text';

// 默认货币（采购订单用）
export const CURRENCY_TYPE_PURCHASE_ORDER = {
  currencyTypeId: 1,
  currencyName: '人民币',
  currencyCode: '¥',
  currencyRate: 1,
};
